# 基础镜像
FROM openapi.enfi.com.cn:30012/library/node:22.19.0-alpine AS build

# 设置工作目录
WORKDIR /app

# 复制源代码
COPY . .

RUN ls -al

# 安装 Yarn 包管理器（如果镜像中没有安装）
#RUN npm install -g yarn --registry https://registry.npmmirror.com

#RUN npm config set registry https://registry.npmmirror.com

# 安装依赖
RUN npm install --registry https://registry.npmmirror.com
#RUN yarn install --registry https://registry.npmmirror.com

# 安装缺少的依赖
#RUN npm install less@3.13.1 less-loader@6.2.0 --save-dev

RUN npm run build:prod
#RUN yarn build

RUN ls -al /app/dist

FROM openapi.enfi.com.cn:30012/library/nginx:1.21.6

COPY --from=build /app/dist /usr/share/nginx/html

#COPY ./zgef /usr/share/nginx/html

# 复制conf文件到路径
COPY ./deploy/nginx.conf /etc/nginx/nginx.conf

RUN ls -al /usr/share/nginx/html

EXPOSE 80

# 启动 Nginx
CMD ["nginx", "-g", "daemon off;"]